package com.ate.lib_core.http.factory;

import com.ate.lib_core.http.product.HttpRetrofitGetDataImpl;
import com.ate.lib_core.http.product.HttpRetrofitNetworkImpl;
import com.ate.lib_core.http.product.HttpRetrofitUploadImpl;
import com.ate.lib_core.http.product.IRetrofitProduct;

import retrofit2.Retrofit;

/**
 * @author Ate
 * @description:
 * @date :2020/12/10 11:12
 */
public class RetrofitFactory implements IRetrofitFactory {
    private static RetrofitFactory retrofitFactroy;

    public static RetrofitFactory getInstance() {
        if (retrofitFactroy == null) {
            retrofitFactroy = new RetrofitFactory();
        }
        return retrofitFactroy;
    }


    private HttpRetrofitNetworkImpl network = null;
    private HttpRetrofitUploadImpl upload = null;
    private HttpRetrofitGetDataImpl getdata= null;
    @Override
    public IRetrofitProduct createRetrofit(RetrofitType type) {
        switch (type){
            case NETWORK:
                if (network==null){
                    network = new HttpRetrofitNetworkImpl();
                }
                return network;

            case UPLOAD:
                if (upload ==null){
                    upload = new HttpRetrofitUploadImpl();
                }
                return upload;
            case GETDATA:
                if (getdata ==null){
                    getdata = new HttpRetrofitGetDataImpl();
                }
                return getdata;

        }
        return null;
    }
}
